<%--
  Created by IntelliJ IDEA.
  User: xiaoxiang
  Date: 2021/10/25
  Time: 14:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>index</title>
</head>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.4.1.js"></script>
<script src="${pageContext.request.contextPath}/static/js/tools.js"></script>
<script src="${pageContext.request.contextPath}/static/js/tables.js"></script>
<script src="${pageContext.request.contextPath}/static/js/ajax.js"></script>
<body>

<%
    request.setCharacterEncoding("utf-8");

    String userName = request.getParameter("username");
    String password = request.getParameter("password");


    Cookie mycook=new Cookie("userInfo",userName+"#"+password);  //设置cookie对象
    mycook.setMaxAge(60*60*20*365); //设置cookie有效期
    response.addCookie(mycook);//把cookie对象发送到客户端进行存储
%>




<div id = 'username' style="float:left"></div>&nbsp;&nbsp;欢迎登录!!!<br />
<!--商品的表格-->
<h3>货物信息</h3>
<button type="button" id="goods" onclick="getGoods()">查询商品</button><br /><br />
<div  style="width:1000px;height:200px; overflow:scroll">
    <table id="table-goods" border="1" rules="all" style="width:980px; height:20px; text-align:center">
        <tr>
            <th>ID</th>
            <th>货物名称</th>
            <th>货物价格</th>
        </tr>
    </table>
</div>
<!-- 查询用户信息 -->
<h3>用户信息</h3>
<button type="button" style="float:left" id="users" onclick="getDetails()">查询用户信息</button>&nbsp;&nbsp;&nbsp;&nbsp;
<button type="button" onclick="updateDetails()">修改用户信息</button><br /><br />
<div  style="width:1000px;height:50px; overflow:auto">
    <table id="table-user" border="1" rules="all" style="width:980px; height:20px; text-align:center">
        <tr>
            <th>ID</th>
            <th>用户名</th>
            <th>地址</th>
            <th>年龄</th>
            <th>性别</th>
        </tr>
        <tr>
            <th id="details_id"></th>
            <th id="details_username"></th>
            <th><input style="width:100%" id="details_address" value="地址" type="input"></th>
            <th><input style="width:100%" id="details_age" value="年龄" type="input"></th>
            <th><input style="width:100%" id="details_sex" value="性别" type="input"></th>
        </tr>
    </table>
</div>
<!-- 查询订单信息 -->
<h3>订单信息</h3>
<button type="button" id="select_orders" onclick="getOrders()">查询订单信息</button><br />

<table>
    <tr>
        <th>用户名</th>
        <th>货物名称</th>
    </tr>
    <tr>
        <th><input id="orders_username" type ="input" ></th>
        <th><input id="orders_goodname" type ="input" ></th>
        <th><button type="button" id="insert_orders" onclick="insertOrder()">插入订单</button></th>
    </tr>
</table>
<div  style="width:1000px;height:200px; overflow:scroll">
    <table id="table-orders" border="1" rules="all" style="width:980px; height:20px; text-align:center">
        <tr>
            <th>订单号</th>
            <th>用户名</th>
            <th>用户地址</th>
            <th>货物名称</th>
        </tr>
    </table>
</div>


</body>


<script>
    var username = '<%=userName%>'
    var password = '<%=password%>'
    getUserId(username, password);
</script>



<script>
    var username = '<%=userName%>'
    console.log(username)
    if (username != null)
        document.getElementById('username').innerText = username.toString()
</script>



</html>
